package ru.dc.gui.swing.util;

import ru.dc.object.events.hub.SearchResultRecieved;

import javax.swing.*;
import java.awt.*;

/**
 * <pre>
 * User: Penkov Vladimir
 * Date: 02.11.2010
 * Time: 15:41:23
 * </pre>
 */
public class SearchResultsRenderer extends FilenameRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        if (value instanceof SearchResultRecieved) {

            SearchResultRecieved sr = (SearchResultRecieved) value;
            String filename = sr.getFilename();
            JLabel label = (JLabel) super.getTableCellRendererComponent(table, filename, isSelected, hasFocus, row, column);
            if (sr.isDirectory()) {
                Icon icon = IconLoader.getInstance().getIcon("icon_dir.gif");
                label.setIcon(icon);
            }
            return label;
        }
        else {
            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    }
}
